<?php

/*
 * Copyright (c) 2012-2013 Aalto University and University of Helsinki
 * MIT License
 * see LICENSE.txt for more information
 */

// use Composer autoloader to automatically load library classes
require_once('vendor/autoload.php');

require_once("model/Model.php");

class Controller {

  public $model;
  
  public function __construct() {
    $this->model = new Model();
  }

  /**
   * Sets the locale language properties from the parameter (used by gettext and some Model classes).
   * @param string $lang language parameter eg. 'fi' for Finnish.
   */
  public function setLanguageProperties($lang) {
    if ($lang == 'fi') {
      // Set language to finnish
      putenv('LC_ALL=fi_FI.utf8');
      setlocale(LC_ALL, 'fi_FI.utf8');
    } else if ($lang == 'sv') {
      // Set language to swedish
      putenv('LC_ALL=sv_SE.utf8');
      setlocale(LC_ALL, 'sv_SE.utf8');
    } else if ($lang == 'en') {
      // Set language to english
      putenv('LC_ALL=en_GB.utf8');
      setlocale(LC_ALL, 'en_GB.utf8');
    } else {
      trigger_error("Unsupported language '$lang', not setting locale", E_USER_WARNING);
    }
  }
  
}

?>
